<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>煤炭管理系统-登录</title>
    <#include "base/base-css.ftl">
    <link rel="stylesheet" href="/static/css/login.css">
</head>

<body>
<div class="login-bg">
    <div class="login-form-wrapper">
        <h2>煤炭管理系统</h2>
        <form class="layui-form">
            <div class="layui-form-item login-input">
                <input type="text" name="username" required
                       lay-verify="required" placeholder="请输入账号" lay-reqtext="账号不能为空" autocomplete="off"
                       class="layui-input txt">
            </div>
            <div class="layui-form-item login-input">
                <input type="password" name="password"
                       required lay-verify="required" placeholder="请输入密码" lay-reqtext="密码不能为空"
                       autocomplete="off" id="password" class="layui-input txt">
                <div class="showpass icon_see"></div>
            </div>
            <div class="layui-form-item login-input verify_img ">
                <input type="text" name="checkcode"
                       required lay-verify="required" placeholder="请输入验证码" lay-reqtext="验证码不能为空"
                       autocomplete="off" id="checkcode" class="layui-input txt">
                <img id="verify_code" style="cursor: pointer" src="/user/public/code" alt="验证码">
            </div>
            <div class="layui-form-item">
                <button class="layui-btn login-btn" lay-submit lay-filter="login">立即登录</button>
            </div>
        </form>
        <div style="color: #f0f0f0">
        <div><span>测试账号:guanli lingdao xiaowang xuanchuan</span></div>
        <div><span>密码皆为:123123</span></div>
        </div>
    </div>
</div>
<#include "base/base-js.ftl">
<script>
    layui.use(['layer', 'form', 'element', 'jquery'], function () {
        let layer = layui.layer, form = layui.form, $ = layui.jquery;
        $("#verify_code").click(function () {
            this.src = '/user/public/code?' + Math.random()
        })
        var nosee = true
        $(".showpass").click(function () {
            var pwd= $("#password"),icon = $(this)
            if (nosee) {
                pwd.attr("type","text")
                icon.removeClass("icon_see").addClass("nosee")
                nosee = false
            }else{
                pwd.attr("type","password")
                $(this).removeClass("nosee").addClass("icon_see")
                nosee = true
            }
            return false
        })

        form.on('submit(login)', function (data) {
            $.ajax({
                type: "POST",
                url: "/user/public/login",
                data: data.field,
                success: function (data) {
                    if (data.isSuccess){
                        window.location = "/sys/main"
                    } else {
                        layer.msg(data.msg)
                    }
                }
            });
            return false;
        });
    });
</script>
</body>
</html>